package com.mmo.cq.game.script.user;

import com.mmo.cq.game.server.bean.server.ServerConfig;
import com.mmo.cq.game.server.bean.user.UserInfo;
import com.mmo.cq.game.server.data.DataCenter;
import org.bson.BsonInt32;
import org.bson.BsonString;
import org.bson.Document;
import org.wxd.batis.mongodb.MongoDataHelper;
import org.wxd.field.extend.SLFunction1;

import javax.annotation.Resource;

/**
 * 玩家管理
 *
 * @author: Troy.Chen(無心道, 15388152619)
 * @version: 2023-02-10 15:41
 **/
public class UserModule {

    @Resource ServerConfig serverConfig;
    @Resource MongoDataHelper mongoDataHelper;
    @Resource DataCenter dataCenter;

    /** 这里所有的都会加载 ，包括跨服的数据 */
    public UserInfo load(int sid, String account) throws Exception {


        final Document whereDocument = new Document();
        SLFunction1<UserInfo, Integer> getSId = UserInfo::getSId;
        whereDocument.append(getSId.ofMethodName(), new BsonInt32(sid));

        SLFunction1<UserInfo, String> getAccount = UserInfo::getAccount;
        whereDocument.append(getAccount.ofMethodName(), new BsonString(account));
        UserInfo userInfo = mongoDataHelper.queryEntity(UserInfo.class, whereDocument);
        if (userInfo != null) {

        }
        return null;
    }

    public UserInfo getUserInfo(long uid) {
        return null;
    }

}
